package com.ruoyi.subject.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import com.ruoyi.subject.domain.SubjectJudge;
import com.ruoyi.subject.service.ISubjectJudgeService;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课题评审Controller
 * 
 * @author yepanpan
 * @date 2021-03-15
 */
@Api("课题评审管理")
@RestController
@RequestMapping("/subject/judge")
public class SubjectJudgeController extends BaseController
{
    @Autowired
    private ISubjectJudgeService subjectJudgeService;

    /**
     * 查询课题评审列表
     */
    @ApiOperation("查询课题评审列表")   
    @GetMapping("/my")
    public TableDataInfo my(SubjectJudge subjectJudge)
    {
    	subjectJudge.setCheckUserId(SecurityUtils.getLoginUser().getUser().getUserId());
        startPage();
        List<SubjectJudge> list = subjectJudgeService.selectSubjectJudgeList(subjectJudge);
        return getDataTable(list);
    }
    
    /**
     * 查询课题评审列表
     */
    @ApiOperation("查询课题评审列表")   
    @PreAuthorize("@ss.hasPermi('subject:judge:list')")
    @GetMapping("/list")
    public TableDataInfo list(SubjectJudge subjectJudge)
    {
        startPage();
        List<SubjectJudge> list = subjectJudgeService.selectSubjectJudgeList(subjectJudge);
        return getDataTable(list);
    }

    /**
     * 导出课题评审列表
     */
    @ApiOperation("导出课题评审列表")    
    @PreAuthorize("@ss.hasPermi('subject:judge:export')")
    @Log(title = "课题评审", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SubjectJudge subjectJudge)
    {
        List<SubjectJudge> list = subjectJudgeService.selectSubjectJudgeList(subjectJudge);
        ExcelUtil<SubjectJudge> util = new ExcelUtil<SubjectJudge>(SubjectJudge.class);
        return util.exportExcel(list, "judge");
    }

    /**
     * 获取课题评审详细信息
     */
    @ApiOperation("获取课题评审详细信息")
    @ApiImplicitParam(name = "id", value = "课题评审ID", required = true, dataType = "int", paramType = "path") 
    @PreAuthorize("@ss.hasPermi('subject:judge:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(subjectJudgeService.selectSubjectJudgeById(id));
    }

    /**
     * 新增课题评审
     */
    @ApiOperation("新增课题评审")
    @PreAuthorize("@ss.hasPermi('subject:judge:add')")
    @Log(title = "课题评审", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SubjectJudge subjectJudge)
    {
        return toAjax(subjectJudgeService.insertSubjectJudge(subjectJudge));
    }

    /**
     * 修改课题评审
     */
    @ApiOperation("修改课题评审")  
    @PreAuthorize("@ss.hasPermi('subject:judge:edit')")
    @Log(title = "课题评审", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SubjectJudge subjectJudge)
    {
        return toAjax(subjectJudgeService.updateSubjectJudge(subjectJudge));
    }

    /**
     * 删除课题评审
     */
    @ApiOperation("删除课题评审")
    @ApiImplicitParam(name = "id", value = "课题评审ID", required = true, dataType = "int", paramType = "path") 
    @PreAuthorize("@ss.hasPermi('subject:judge:remove')")
    @Log(title = "课题评审", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(subjectJudgeService.deleteSubjectJudgeByIds(ids));
    }
}
